Skip to content

Conversation

@matklad
Copy link
Contributor

@matklad matklad commented Jan 25, 2020

No description provided.

@matklad
Copy link
Contributor Author

matklad commented Jan 26, 2020

bors try

bors bot added a commit that referenced this pull request Jan 26, 2020
@matklad matklad changed the title Tweak threadpool Fix thread priority problems on windows Jan 26, 2020
@matklad
Copy link
Contributor Author

matklad commented Jan 26, 2020

bors try

@bors
Copy link
Contributor

bors bot commented Jan 26, 2020

try

Already running a review

@matklad
Copy link
Contributor Author

matklad commented Jan 26, 2020

bors try

@bors
Copy link
Contributor

bors bot commented Jan 26, 2020

try

Already running a review

@lnicola
Copy link
Member

lnicola commented Jan 26, 2020

Would it make sense to reduce the priority of the thread pool threads instead? This way it would work on other platforms, too.

@bors
Copy link
Contributor

bors bot commented Jan 26, 2020

try

Build failed

  • Rust (windows-latest)

@matklad
Copy link
Contributor Author

matklad commented Jan 26, 2020

bors try

I would have lowered thread pool priority, but there’s no easy api to customize thread creation. But it seems to be orthogonal to being cross platform?

Ideally, I’d prefer to not tweak propiorities at all and just rely on fairness, but on windows we specifically hit an unfair case.

@bors
Copy link
Contributor

bors bot commented Jan 26, 2020

try

Already running a review

@bors
Copy link
Contributor

bors bot commented Jan 26, 2020

try

Timed out

@matklad
Copy link
Contributor Author

matklad commented Jan 26, 2020

bors r+

bors bot added a commit that referenced this pull request Jan 26, 2020
2906: Fix thread priority problems on windows r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
@bors
Copy link
Contributor

bors bot commented Jan 26, 2020

Build succeeded

  • Rust (macos-latest)
  • Rust (ubuntu-latest)
  • Rust (windows-latest)
  • TypeScript

@bors bors bot merged commit 9faebd9 into rust-lang:master Jan 26, 2020
@lnicola
Copy link
Member

lnicola commented Jan 26, 2020

I would have lowered thread pool priority, but there’s no easy api to customize thread creation.

Ah, I missed that. I know that some crates like rayon have a thread creation callback, but threadpool doesn't. I was under the impression that you've recently switched to a different thread pool implementation, but no, it's the same one.

But it seems to be orthogonal to being cross platform?

On Linux you can decrease a thread's priority (nice), but not increase it unless you have CAP_SYS_NICE.

In general, I wouldn't expect schedulers to be fair. They're a mess of heuristics (like the priority boosting that Windows does in some cases) that either improve responsiveness or throughput. In the recent discussion about user-space spinlocks, Torvalds pointed out that fairness is bad for throughput, on smaller systems, but:

Pretty much every time we picked an unfair - but fast - locking model in the kernel, we ended up regretting it eventually, and had to add fairness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants